const path = require('path')
module.exports = function (plop) {


	// 需要判断一下当前是新建还是重写？
	// 
	plop.setGenerator('basics', {
		description: 'this is a skeleton plopfile',
		prompts: [{
			type:"input",
			name:'name',
			message:'路由名称',
		},{
			type:'input',
			name:'ChineseName',
			message:'元信息'
		}],
		actions:function(answer){
			let actions=[]
			actions.push({
				type:'add',
				path:'src/router/module/{{name}}.ts',
				templateFile:'plopHbs/router.hbs'
			})
			let item = {
				type:'modify',
				path:"src/router/module/index.ts",
				pattern:/(\/\/new router)/gi,
				template:'import {{name}} from "./{{name}}"\r\n$1'
			}
			
			let item3 = {
				type: 'modify',
				path: "src/router/module/index.ts",
				pattern: /(\/\/new export)/gi,
				template: '...{{name}},\r\n\$1'
			}
		
			actions.push({
				type:'add',
				path:"src/views/{{name}}/index.vue",
				templateFile:'plopHbs/index.hbs'
			})
			actions.push(item,item3)
			return actions
		}
	});

};